#include "stopnav.h"
#include "ui_stopnav.h"
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlError>
#include <QMessageBox>
#include <QSqlQuery>
#include "park.h"
StopNav::StopNav(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::StopNav)
{
    ui->setupUi(this);


}

StopNav::~StopNav()
{
    delete ui;
}

void StopNav::on_pushButton_clicked()
{    QSqlQuery query;
     //------------入场路线规划---------------
     park park1(query);
     //获取预约车位id
     park1.set_id(place_id);
     int id=park1.get_id();
     park1.get_position(id);
     int x=park1.get_x();
     int y=park1.get_y();
     QString route=park1.countroute(x,y,id);
     QString text=park1.text(x,y,id);
     qDebug()<<"您的车位是："<<"("<<x<<","<<y<<")";
     qDebug()<<"您需要："<<text;
     qDebug()<<"路线规划为："<<route;
     QString s1=QString("您的车位是: (%1,%2)").arg(x).arg(y);
     QString s2=QString("您需要: ")+text;
     QString s3=QString("路线规划为：")+route;
     QString s=s1+"\n\n\n"+s2+"\n\n\n"+s3;
     ui->textEdit->setText(s);

}
void StopNav::setid(int id){
    this->place_id=id;
}

void StopNav::on_pushButton_2_clicked()
{   ui->textEdit->setText("");
    this->close();
}
